'''
# -*- coding:utf-8 -*-
# @Project: DevOps_api
# @Date: 2023/3/23 - 16:28
# @Author: ysg
# @Describe: 

serializer.py
'''

from rest_framework import serializers
from charts.models import Host
from dev.models import Monitorpy, Fork_version, Log_audit


class HostModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Host
        fields = ['id', 'host_ip', 'host_name_ip']


class MonitorpyModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Monitorpy
        fields = ['id', 'py_title', 'file_name', 'py_describe', 'py_timer', 'py_status', 'start_time', 'host_ip',
                  'py_status_name']
        extra_kwargs = {
            'py_status_name': {'read_only': True},
        }


class FileForkViewModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Fork_version
        fields = ['id', 'ver_name', 'user']


class LogsViewModelSerializer(serializers.ModelSerializer):
    class Meta:
        model = Log_audit
        fields = ['id', 'tag_name', 'log_info', 'user_name', 'handle_time']
